package com.sfdk.graphics.engine.data
{
    import flash.events.EventDispatcher;
    import flash.geom.Rectangle;

    public class NPCDefinition extends EventDispatcher
    {
        private var _npcData:XML;

        private var _spriteName:String;
        private var _limits:Rectangle;
        private var _textName:String;
        private var _npcName:String;
        private var _portraitName:String;

        public function NPCDefinition(npcData:XML) {
            _npcData = npcData;
            init();
        }

        private function init():void {
            _spriteName = _npcData.@sprite;
            _textName = _npcData.@text;
            _npcName = _npcData.@name;
            _portraitName = _npcData.@portraitName;

            var limits:XML = _npcData.limits[0];

            _limits = new Rectangle(limits.@left, limits.@upper, limits.@right - limits.@left, limits.@lower - limits.@upper);
        }

        public function get spriteName():String {
            return _spriteName;
        }

        public function get limits():Rectangle {
            return _limits;
        }

        public function get textName():String {
            return _textName;
        }

        [Bindable]
        public function get npcName():String {
            return _npcName;
        }

        public function set npcName(value:String):void {
            _npcName = value;
        }

        public function get label():String {
            return _npcName;
        }

        public function get portraitName():String {
            return _portraitName;
        }
    }
}
